/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.qlks.controller.phieuthue;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.rowset.WebRowSet;
import uit.ejb.bo.phieuthue.PhieuThueBORemote;
import uit.ejb.bo.phieuthue.PhieuThueBORemoteHome;
import uit.ejb.dto.PhieuThueDTO;

/**
 *
 * @author Restart
 */
public class PhieuThueController {

    private static Context ctx;
    private static PhieuThueBORemoteHome phome;
    private static PhieuThueBORemote pt;
    public PhieuThueController(){

    }

    public static void Register(){
        try{
            ctx = new InitialContext();
            Object obj = ctx.lookup("ejb/PhieuThueBO");
            phome = (PhieuThueBORemoteHome) PortableRemoteObject.narrow(obj, PhieuThueBORemoteHome.class);
            pt=phome.create();
        }
        catch(Exception e){
        }
    }

    public static boolean phieuThue_Insert(PhieuThueDTO phieuthue) {
        try{
            Register();
            return pt.phieuThue_Insert(phieuthue);
        }catch(Exception e){
            return false;
        }
    }

    public static boolean phieuThue_Update(PhieuThueDTO phieuthue) {
        try{
            Register();
            return pt.phieuThue_Update(phieuthue);
        }catch(Exception e){
            return false;
        }
    }

    public static boolean phieuThue_Delete(String id) {
        try{
            Register();
            return pt.phieuThue_Delete(id);
        }catch(Exception e){
            return false;
        }
    }

    public static WebRowSet phieuThue_GetByAll() {
        try{
            Register();
            return pt.phieuThue_GetByAll();
        }catch(Exception e){
            return null;
        }
    }

    public static WebRowSet phieuThue_GetById(String id) {
        try{
            Register();
            return pt.phieuThue_GetById(id);
        }catch(Exception e){
            return null;
        }
    }

    public static WebRowSet phieuThue_GetByTop(String top, String where, String order) {
        try{
            Register();
            return pt.phieuThue_GetByTop(top, where, order);
        }catch(Exception e){
            return null;
        }
    }

    public static String phieuThue_GetMaxMaPT() {
        try{
            Register();
            return pt.phieuThue_GetMaxMaPT();
        }catch(Exception e){
            return null;
        }
    }
}
